package com.jintian.smart.kernel.security.provider;

import com.jintian.smart.base.api.security.constant.DataTracerTypeEnum;
import com.jintian.smart.base.api.security.form.DataTracerForm;
import com.jintian.smart.base.api.security.provider.IDataTracerProvider;
import com.jintian.smart.kernel.security.service.DataTracerService;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

@DubboService(timeout = 6000)
public class DataTracerProvider implements IDataTracerProvider {
    @Resource
    private DataTracerService dataTracerService;

    /**
     * 保存【删除】数据变动记录
     */
    @Override
    public void delete(Long dataId, DataTracerTypeEnum type) {
        dataTracerService.delete(dataId, type);
    }

    /**
     * 保存【新增】数据变动记录
     */
    @Override
    public void insert(Long dataId, DataTracerTypeEnum type) {
        dataTracerService.insert(dataId, type);
    }

    /**
     * 保存【修改】数据变动记录
     */
    @Override
    public void update(Long dataId, DataTracerTypeEnum type, Object oldObject, Object newObject) {
        dataTracerService.update(dataId, type, oldObject, newObject);
    }

    /**
     * 保存数据变动记录
     */
//    @Override
    public void addTrace(DataTracerForm tracerForm) {
        dataTracerService.addTrace(tracerForm);
    }

    /**
     * 保存数据变动记录
     */
//    @Override
    public void addTrace(Long dataId, DataTracerTypeEnum type, String content) {
        dataTracerService.addTrace(dataId, type, content);
    }

    /**
     * 获取变更内容
     */
//    @Override
    public String getChangeContent(Object object) {
        return dataTracerService.getChangeContent(object);
    }

    /**
     * 获取变更内容
     */
//    @Override
    public String getChangeContent(Object oldObject, Object newObject) {
        return dataTracerService.getChangeContent(oldObject, newObject);
    }

    /**
     * 保存【批量删除】数据变动记录
     */
    @Override
    public void batchDelete(List<Long> dataIdList, DataTracerTypeEnum type) {
        dataTracerService.batchDelete(dataIdList, type);
    }
}
